class Solution:
    def isValidSudoku(self, board):
        cent_dic = {0: 1, 1: 1, 2: 1, 3: 4, 4: 4, 5: 4, 6: 7, 7: 7, 8: 7}
        for hang_num, hang_list in enumerate(board):
            for lie_num, num in enumerate(hang_list):
                if num == ".":
                    continue
                for i in range(0, 9):
                    if (i != lie_num and board[hang_num][i] == num) or \
                            (i != hang_num and board[i][lie_num] == num):
                        return False
                for j in range(cent_dic[lie_num]-1, cent_dic[lie_num] + 2):
                    for i in range(cent_dic[hang_num]-1, cent_dic[hang_num] + 2):
                        if j == lie_num and i == hang_num:
                            continue
                        elif board[i][j] == num:
                            print(i, j)
                            print(hang_num, lie_num)
                            return False
        else:
            return True


a = Solution()
print(a.isValidSudoku([["5","3",".",".","7",".",".",".","."],
                       ["6",".",".","1","9","5",".",".","."],
                       [".","9","8",".",".",".",".","6","."],
                       ["8",".",".",".","6",".",".",".","3"],
                       ["4",".",".","8",".","3",".",".","1"],
                       ["7",".",".",".","2",".",".",".","6"],
                       [".","6",".",".",".",".","2","8","."],
                       [".",".",".","4","1","9",".",".","5"],
                       [".",".",".",".","8",".",".","7","9"]]))

